package edu.zut.hys.jsskateboard.service;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.DataAbilityHelper;
import ohos.aafwk.ability.DataAbilityRemoteException;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.annotation.f2pautogen.InternalAbility;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.location.GeoAddress;
import ohos.location.GeoConvert;
import ohos.media.image.ImageSource;
import ohos.media.image.PixelMap;
import ohos.media.photokit.metadata.AVStorage;
import ohos.utils.net.Uri;

import java.io.*;

@InternalAbility(registerTo = "edu.zut.hys.jsskateboard.MainAbility") // 此处registerTo的参数为项目中MainAbility类的全称
public class TestService extends Ability {
    private static final HiLogLabel label = new HiLogLabel(3, 0xD001100, "Demo");

    public int add(int num1, int num2) {
        return num1 + num2;
    }

    public String decode(String latitude, String longitude){
        String res = "";
        GeoConvert geoConvert = new GeoConvert();
        GeoAddress geoAddress = null;
        try {
            geoAddress = geoConvert.getAddressFromLocation(Double.valueOf(latitude), Double.valueOf(longitude), 1).get(0);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(geoAddress!=null){
            res += geoAddress.getCountryName()+" ";
            res += geoAddress.getAdministrativeArea()+" ";
            res += geoAddress.getLocality()+" ";
            res += geoAddress.getSubLocality()+" ";
            res += geoAddress.getRoadName()+" ";
            res += geoAddress.getSubRoadName()+" ";
            res += geoAddress.getPlaceName()+" ";
        }

        return res;
    }



}